<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <div id="app"></div>
  <template id="pengfan">
    <component-a></component-a>
    <component-b></component-b>

    <!-- 不推荐使用 -->
    <!-- <ComponentC></ComponentC> -->
    <component-c></component-c>
  </template>

  <template id="component-a">
    <h2>{{title}}</h2>
    <p>{{desc}}</p>
    <button @click="btnClick">按钮点击</button>
  </template>

  <template id="component-b">
    <h2>{{message}}</h2>
  </template>

  <template id="component-c">
    <h2>我是组件ComponentC</h2>
  </template>


  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: "#pengfan"
    };
    const app = Vue.createApp(App);

    //使用app注册一个全局组件app.component()
    //全剧组件：意味着注册这个组件可以在任何的组件模板中使用
    app.component("component-a", {
      template: "#component-a",
      data() {
        return {
          title: "我是标题",
          desc: "我是内容，哈哈哈"
        }
      },
      methods: {
        btnClick() {
          console.log("按钮的点击");
        }
      }
    });

    app.component("component-b", {
      template: "#component-b",
      data() {
        return {
          message: "Hello World"
        }
      }
    });

    app.component("component-c", {
      template: "#component-c"
    })






    app.mount("#app")
  </script>
</body>

</html>